﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using FileCopier;

namespace MASSBAckUp
{
    public partial class FileReplaceForm : Form
    {
        private FileInfo FSrc;
        private FileInfo FDst;

        public CopyConflictResolution Resolution = new CopyConflictResolution();
        
        public FileReplaceForm(FileInfo Src, FileInfo Dst)
        {
            FSrc = Src;
            FDst = Dst;
            InitializeComponent();

            SrcPicture.LoadAsync(Src.FullName);
            SrcFileName.Text = "Копируемый назначения: " + Src.Name + " (" + Src.FullName + ")";
            SrcSize.Text = "Размер: " + Src.Length + " байт.";
            if (SrcPicture.Image != null)
            {
                SrcSize.Text += " Размер картинки: " + SrcPicture.Image.Size.Width.ToString() + "x"+ SrcPicture.Image.Size.Height.ToString();
            }
            SrcTime.Text = "Модиицирован: " + Src.LastWriteTime.ToString("dd MMM yyyy h:mm:ss.ff");

            DstPicture.LoadAsync(Dst.FullName);
            DstFileName.Text = "Файл назначения: " + Dst.Name + " (" + Dst.FullName + ")";
            DstSize.Text = "Размер: " + Dst.Length + " байт.";
            DstTime.Text = "Модиицирован: " + Dst.LastWriteTime.ToString("dd MMM yyyy h:mm:ss.ff");
            if (DstPicture.Image != null)
            {
                DstSize.Text += " Размер картинки: " + DstPicture.Image.Size.Width.ToString() + "x" + DstPicture.Image.Size.Height.ToString();
            }

        }

        private void DontCopyButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Resolution.Resolution = CopyConflictResolutionType.DontCopy;
            Resolution.UseAlways = SameCheckBox.Checked;
            Close();
        }

        private void ReplaceButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Resolution.Resolution = CopyConflictResolutionType.Replace;
            Resolution.UseAlways = SameCheckBox.Checked;
            Close();
        }

        private void RenameButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Resolution.Resolution = CopyConflictResolutionType.Rename;
            Resolution.UseAlways = SameCheckBox.Checked;
            Close();
        }

        private void CancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
